package gates;

import java.awt.Graphics;
import java.util.LinkedList;
import java.util.List;

import master.QuantumRegister;

/**
 * 	simple swap gates that applies three CNot's in succession to swap the two qBits
 * 
 * @author Oliver Wiese
 *
 *
 */
public class SwapGate extends  QuantumGate {
	
	int bit1,bit2;
	QuantumGate gate1, gate2;
	
	/**
	 * 
	 * @param bit1
	 * @param bit2
	 */
	public SwapGate(int bit1, int bit2){
		this.bit1 = bit1;
		this.bit2 = bit2;
		gate1 = new Cnot(bit1, bit2);
		gate2 = new Cnot(bit2, bit1);
	}

	/**
	 * acts with the Swap Gate on the given register
	 * @param register
	 */
	public void actOnReg(QuantumRegister register) {
		gate1.actOnReg(register);
		gate2.actOnReg(register);
		gate1.actOnReg(register);


		
	}


	
	/**
	 * Returns a list with all the qBits the register acts on
	 */
	public int[] getActingBits() {
		int[] actingBits = new int[2];
		actingBits[0] = bit1+1;
		actingBits[1] = bit2+1;
		return actingBits;
	}


}
